Những câu hỏi liên quan
k_o_t_en
Xem chi tiết
Phía sau một cô gái
8 tháng 5 2023 lúc 20:22

program BaiTap;

var

      A: array[1..150] of integer;

      N, i, sum: integer;

begin

      write('Nhap so phan tu cua day A (N <= 150): ');

      readln(N);

      for i := 1 to N do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(A[i]);

      end;

      writeln('Day so vua nhap la:');

      for i := 1 to N do

            write(A[i], ' ');

      writeln;

      sum := 0;

      for i := 1 to N do

            if A[i] mod 2 = 0 then

                  sum := sum + A[i];

      writeln('Tong cac phan tu chan trong day la: ', sum);

      readln;

end.

Bình luận (1)
hà phương
Xem chi tiết
Nguyễn Hoàng Tiến
29 tháng 7 2023 lúc 11:21

đitf

Bình luận (0)
Nguyễn Khải Minh
Xem chi tiết
Kiều Vũ Linh
30 tháng 4 2022 lúc 7:22

Var a:array[1..15] of integer;

i,s:integer;

Begin

I:=1;

While i<=15 do

Begin

Write('Nhap phan tu thu ',i,' = ');readln(a[i]);

s:=s+a[i];

i:=i+1;

End;

Write('Tong la ',s);

Readln;

End.

Bình luận (0)
HUY HUỲNH QUANG
Xem chi tiết
Kiều Vũ Linh
5 tháng 5 2023 lúc 14:54

Bài 5:

Var a:array:[1..1000] of integer;

i,n,max:integer;

sc, sl:longint;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');rreadlna[i]);

If a[i] mod 2 = 0 then sc:=sc+b[i];

If a[i] mod 2 <> 0 then sl:=sl+a[i];

End;

max:=a[1];

For i:=2 to n do

If a[i] > max then max:=a[i];

Writeln('Tong cac so chan la ',sc);

Writeln('Tong cac so le la ',sl);

write('So lon nhat la ',max);

Readln

End.

Bình luận (1)
Nguyễn Trần Hồng Ngọc
Xem chi tiết
Phía sau một cô gái
7 tháng 5 2023 lúc 20:02

program TinhTBCTimSoNT;

var
  ten, lop: string;
  n, i, tong, dem: integer;
  A: array [1..11] of integer;
  trung_binh: real;

function LaSoNguyenTo(x: integer): boolean;
var
  i: integer;
begin
  if x < 2 then
    LaSoNguyenTo := false
  else if x = 2 then
    LaSoNguyenTo := true
  else if x mod 2 = 0 then
    LaSoNguyenTo := false
  else
  begin
    i := 3;
    while (i <= trunc(sqrt(x))) and (x mod i <> 0) do
      i := i + 2;
    LaSoNguyenTo := x mod i <> 0;
  end;
end;

begin
  // Nhập tên và lớp của học sinh
  write('Nhập tên của học sinh: ');
  readln(ten);
  write('Nhập lớp: ');
  readln(lop);

  // Nhập dãy số nguyên và tính trung bình cộng
  repeat
    write('Nhập số phần tử của dãy số (n<12): ');
    readln(n);
  until n < 12;
  tong := 0;
  for i := 1 to n do
  begin
    write('Nhập phần tử thứ ', i, ': ');
    readln(A[i]);
    tong := tong + A[i];
  end;
  trung_binh := tong / n;

  // In tên, lớp, dãy số và trung bình cộng ra màn hình
  writeln('Học sinh: ', ten);
  writeln('Lớp: ', lop);
  write('Dãy số: ');
  for i := 1 to n do
    write(A[i], ' ');
  writeln;
 
  // In các số nguyên tố của dãy số ra màn hình
  writeln('Các số nguyên tố của dãy số:');
  for i := 1 to n do
    if LaSoNguyenTo(A[i]) then
      writeln(A[i]);
end.

Bình luận (0)
Bé Kunz
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 22:24

Bài 1: 

uses crt;

var a:array[1..200]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i] mod 5=0 then t:=t+a[i];

writeln('Tong cac so chia het cho 5 la: ',t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 22:25

Bài 2: 

uses crt;

var st:string;

d,i:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

  if st[i]=#32 then delete(st,i,1);

writeln(st);

readln;

end.

Bình luận (0)
scar titan
28 tháng 7 2021 lúc 10:11

python có ko bạn

 

Bình luận (0)
Ha Tran
Xem chi tiết
Ngô Bá Hùng
14 tháng 4 2023 lúc 22:26

n = int(input("Nhập số phần tử của dãy số: "))
numbers = []

# Nhập dãy số nguyên
for i in range(n):
    num = int(input(f"Nhập số thứ {i+1}: "))
    numbers.append(num)

# Xuất dãy số nguyên
print("Dãy số vừa nhập là:", end=" ")
for num in numbers:
    print(num, end=" ")

Bình luận (3)
Ha Tran
Xem chi tiết
Phía sau một cô gái
14 tháng 4 2023 lúc 20:41

program nhapdayso;

var

      a: array[1..100] of integer;

      n, i: integer;

begin

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

      readln(a[i]);

      end;

      writeln('Day so ban vua nhap la:');

      for i := 1 to n do

            write(a[i], ' ');

      readln;

end.

Bình luận (0)
vy tường
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:02

uses crt;

var a:array[1..100]of integer;

i,n,x:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

write('Nhap x='); readln(x);

for i:=1 to n do 

  if a[i]=x then write(i:4);

readln;

end.

Bình luận (0)